<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link type="text/css" href="resources/css/jquery-ui.css" 		rel="stylesheet" />
	<link type="text/css" href="resources/css/flexigrid.css" 		rel="stylesheet">
	<link type="text/css" href="resources/css/main.css" 			rel="stylesheet"/>
	<link type="text/css" href="resources/css/ui.jqgrid.css"  media="screen" 	rel="stylesheet" />
	
	<script type="text/javascript" src="resources/jquery.min.js"></script>
	<script type="text/javascript" src="resources/jquery-ui.min.js"></script>
	<script type="text/javascript" src="resources/flexigrid.js"></script>
	
	<script type="text/javascript" src="resources/i18n/grid.locale-en.js" ></script>
	<script type="text/javascript" src="resources/jquery.jqGrid.src.js" ></script>
	
    <style>
    #toolbar {
        padding: 10px 4px;
    }
    
    #jqUsersList {
        font-size: 14px;
    }
    
    </style>	
<script type="text/javascript">
$(function(){ 
	/* ------------------ GRID FUNCTION ----------------- */	
  $("#jqUsersList").jqGrid({
	jsonReader : {
	      root:"rows",
	      page: "page",
	      total: "total",
	      records: "records",
	      repeatitems: false,
	      id: "0"
	   },	  
    url:'json/entity/userManagement/list',
    datatype: 'json',
    mtype: 'GET',
    colNames:['#', 'User Name', 'Login', 'Email', 'Company','Type','#', 'Manager','Менеджер',''],//, 'Order Date', '','','Order Status',''],
    colModel :[ 
      {name:'id', 			index:'id', 					width:10, sortable:false },
      {name:'name',			index:'name', 					width:85, sortable:false },
      {name:'username',		index:'username', 				width:80, sortable:false, fixed:true },
      {name:'email',		index:'email', 					width:100, sortable:false },
      {name:'company',		index:'company', 				width:160, sortable:false },
      {name:'userType.denumirea_ru',		index:'userType.denumirea_ru',	width:60, sortable:false },
      {name:'enabled',		index:'enabled',				width:20, sortable:false, fixed:true,
    	  formatter: enabledFormatter},
      {name:'manager.name',	 index:'manager.name',			width:40, sortable:false, hidden:true },
      //{name:'manager.id',	 index:'manager.id',			width:40, sortable:false, hidden:true },
      {name:'manager.id',	 index:'manager.id',			width:80, 
    	  editable:true,
    	  edittype:'select', formatter:'select',
//    	  editoptions:{ dataUrl: "json/entity/userManagement/listManagers"}},  
    	  editoptions:{value:"10:Sveatollav Covaliov;11:Oxana Chirita;12:Marina Casapu;14:Dmitrii Bordian;15:Cristina Toma"}},
   	  {name:'id', 					index:'id', 	width:60, align:'center', fixed:true, sortable:false, resize:false, 
       	  formatter:'actions', formatoptions:{keys:true}}    	  
    ],
    pager: '#pager',
    toppager: false,
    rowNum:10,
    rowList:[10,20,30],
    sortname: 'id',
    sortorder: 'asc',
    viewrecords: true,
    gridview: true,
    autowidth: true,
    height: 'auto',
    caption: 'User List',
    search: true,
    editurl : 'json/entity/userManagement/edit'
  }); 
  
  function enabledFormatter(cellvalue, options, rowObject) {
	  if (rowObject['enabled'] == 1 ){
		  return "<img src='resources/icons/add.png' width='14' alt='+' title='Activ' />";
	  }  else {
		  return "<img src='resources/icons/delete.png' width='14' alt='-' title='Inactiv' />";
	  }
  };
	
});
	
</script>	
	<title>Insert title here</title>
</head>
<body>

<table id="jqUsersList">
	<tr><td/></tr>
</table>

</body>
</html>
